package com.acwing.partition19;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/28 17:17
 */
public class AC1813方块游戏 {

    private static final int N = 110;
    private static String[] ss1 = new String[N], ss2 = new String[N];
    private static int n = 0;
    private static int[] ans = new int[26], cnt1 = new int[26], cnt2 = new int[26];

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            String[] s = reader.readLine().split(" ");
            ss1[i] = s[0];
            ss2[i] = s[1];
        }
        //枚举每一个木块上的单词，统计要满足当前木块单词的情况下至少需要的数量
        for (int i = 0; i < n; i++) {
            String s1 = ss1[i], s2 = ss2[i];
            for (int j = 0; j < 26; j++) cnt1[j] = cnt2[j] = 0;
            for (int j = 0; j < s1.length(); j++) cnt1[s1.charAt(j) - 'a']++;
            for (int j = 0; j < s2.length(); j++) cnt2[s2.charAt(j) - 'a']++;
            //统计需求量
            for (int j = 0; j < 26; j++) ans[j] += Math.max(cnt1[j], cnt2[j]);
        }
        for (int i = 0; i < 26; i++) writer.write(ans[i] + "\n");
        writer.flush();
    }
}
